﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Pop
{
    class Block:Pallet
    {
        int numberOfHitsToBreak = 1;
        Color color;
        bool enabled;
        SoundEffect soundEffect;

        public int NumberOfHitsToBreak
        {
            get { return numberOfHitsToBreak; }
            set { numberOfHitsToBreak = value;
                if (numberOfHitsToBreak <= 0)
                {
                    enabled = false;
                }
            }

        }

        public bool Enabled
        {
            get { return enabled; }
            set { enabled = value; }

        }
        public SoundEffect SoundEffect
        {
            get { return soundEffect; }
            set { soundEffect = value; }

        }

        public Block(Texture2D texture,Vector2 position, Color color, SoundEffect soundEffect):base(texture,position)        
        {
            this.color = new Color(color.R,color.G,color.B,180);
            this.enabled = true;
            this.size.X = (int)position.X;
            this.size.Y = (int)position.Y;
            this.soundEffect = soundEffect;
        }

        public Block(Texture2D texture, Vector2 position, Color color, SoundEffect soundEffect,int numberOfHitsToBreak)
            : base(texture, position)
        {
            this.numberOfHitsToBreak = numberOfHitsToBreak;
            this.color = new Color(color.R, color.G, color.B, 180);
            this.enabled = true;
            this.size.X = (int)position.X;
            this.size.Y = (int)position.Y;
            this.soundEffect = soundEffect;
        }


        public override void Draw(SpriteBatch spriteBatch)
        {
           if(enabled) spriteBatch.Draw(texture, position, color);
        }
    }
}
